package com.societyGames.faceExercises
{
	import com.societyGames.codeExercise.CodeExercise;
	import com.societyGames.codeExercise.IServiceProvider;
	
	import flash.events.Event;

	public class FaceCodeExercise extends CodeExercise
	{
		protected var _faceSimulation:FaceSimulation;
		
		public function FaceCodeExercise()
		{
			this._faceSimulation = new FaceSimulation(this._actionQueue);
			//When the render is all empty, we want to know.
			this._faceSimulation.render.actionsCompleteEventObject.addEventListener(renderCompleteHandler);
			this.addChild(this._faceSimulation.render);
		}
		
		public override function initialize(serviceProvider:IServiceProvider, xml:XML=null):void
		{	
			super.initialize(serviceProvider, xml);
			this._faceSimulation.initialize(xml);
		}
		
		public function get faceSimulation():FaceSimulation
		{
			return this._faceSimulation;
		}
		
		//ICodeExercise-->
		public override function evaluate():void
		{
			this._faceSimulation.render.complete();
		}
		//<--ICodeExercise
		
		protected function renderCompleteHandler(event:Event):void
		{
			//Derived class should evaluate success
		}
	}
}